package org.NooLab.itexx.app.gui.definition;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ComponentEvent;
import java.awt.event.FocusEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;

import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.text.JTextComponent;

import org.NooLab.itexx.app.gui.handlers.TextFieldHandler;
import org.NooLab.utilities.logging.PrintLog;





class GuiEvents{
	
	ITexxWindowGuiIntf windowGui;
	private PrintLog out;
	
	
	public GuiEvents(ITexxWindowGui2 gui) {
		windowGui = gui;
		out = windowGui.getTexxWindowApp().getAppCommons().out ;
	}
	


	public void jTabbedPaneFocusComponentResized(ComponentEvent evt) {
		// TODO Auto-generated method stub
		
	}

	public void TextFieldDedicatedSearchMouseClicked(MouseEvent evt) {
		// 
		System.err.println("TextFieldDedicatedSearch.mouseClicked, event="+evt);
		
		JTextComponent textfield = windowGui.getTextFieldDedicatedSearch() ;
		String str = textfield.getText() ;
		if (str.toLowerCase().endsWith("...")){
			textfield.setText("") ;
			textfield.setForeground( Color.BLACK) ;
			textfield.repaint() ;
		}

	}

	public void TextFieldDedicatedSearchKeyReleased(KeyEvent evt) {
		// 
		out.print(4,"TextFieldDedicatedSearch.keyReleased, event="+evt);
		// String str = TextFieldDedicatedSearch.getText() ;
		
		// neatly outsourced into a separate object
		(new TextFieldHandler(windowGui, windowGui.getTextFieldDedicatedSearch())).handling( evt );

	}

	
	// ........................................................................
	public void jPanelWebMetaComponentResized( ComponentEvent evt, 
											   JPanel jPanelReqTop, 
											   JPanel jPanelTextFieldHost, 
											   JTextField textFieldDedicatedSearch) {
		// 
		int w=0,h=0;
		
		if (evt!=null){
			
		}
		
		w = jPanelTextFieldHost.getWidth();
		w = jPanelReqTop.getWidth()-42;
		h = textFieldDedicatedSearch.getHeight() ;
		if (w>800)w=800;
		Dimension d = new Dimension(w,h);
		
		if (w<1){
			return;
		}
		textFieldDedicatedSearch.setPreferredSize(d);
		textFieldDedicatedSearch.setSize(d);

		
		w = jPanelReqTop.getWidth()-30;
		h = jPanelTextFieldHost.getHeight() ;
		d = new Dimension(w,h);

		if (w<1){
			return;
		}
		if (w>810)w=810;
		jPanelTextFieldHost.setPreferredSize(d);
		jPanelTextFieldHost.setSize(d);
	}

	public void jPanelWebMetaKeyPressed(KeyEvent evt) {
		// TODO Auto-generated method stub
		
	}

	public void jPanelWebMetaMouseClicked(MouseEvent evt) {
		// TODO Auto-generated method stub
		
	}

	public void jPanelWebMetaMouseWheelMoved(MouseWheelEvent evt) {
		// TODO Auto-generated method stub
		
	}

	public void jPanelWebMetaFocusGained(FocusEvent evt) {
		// TODO Auto-generated method stub
		
	}

	public void jPanelWebMetaFocusLost(FocusEvent evt) {
		// TODO Auto-generated method stub
		
	}

	protected void jPanelHistoryTreeKeyPressed(KeyEvent evt) {
		// TODO Auto-generated method stub
		
	}

	protected void jPanelHistoryTreeComponentResized(ComponentEvent evt) {
		// TODO Auto-generated method stub
		
	}

	protected void jTabbedPaneFocusComponentMoved(ComponentEvent evt) {
		// TODO Auto-generated method stub
		
	}

	protected int jTextAreaFileDropMouseClicked(MouseEvent evt) {
		// TODO Auto-generated method stub
		return 0;
	}

	protected void jPanelFocusContentMainComponentResized(ComponentEvent evt) {
		// TODO Auto-generated method stub
		
	}


	protected void PanelFocusComponentResized(ComponentEvent evt) {
		// TODO Auto-generated method stub
		
	}


	protected void jPanelFocusComponentResized(ComponentEvent evt) {
		// TODO Auto-generated method stub
		
	}

	protected void jPanelPGraphicsComponentResized(ComponentEvent evt) {
		// TODO Auto-generated method stub
		
	}

	protected void jButtonSingleWindowMouseClicked(MouseEvent evt) {
		// TODO Auto-generated method stub
		
	}


	protected void jButtonSingleWindowKeyPressed(KeyEvent evt) {
		// TODO Auto-generated method stub
		
	}

 

	protected void newButtonMouseClicked(MouseEvent evt) {
		// TODO Auto-generated method stub
		
	}
}
